
//////////////////////////////////////////////////////////////////////////////
// Standard includes
// SystemC includes
// ArchC includes

#include "ac_tlm_lock.h"

//////////////////////////////////////////////////////////////////////////////

/// Namespace to isolate memory from ArchC
using user::ac_tlm_lock;

/// Constructor
ac_tlm_lock::ac_tlm_lock( sc_module_name module_name ) :
  sc_module( module_name ),
  target_export("iport")
{
    /// Binds target_export to the memory
    target_export( *this );
    lock = 0;

}

/// Destructor
ac_tlm_lock::~ac_tlm_lock() {
}

/** Internal Write
  * Note: Always write 32 bits
  * @param a is the address to write
  * @param d id the data being write
  * @returns A TLM response packet with SUCCESS
*/
ac_tlm_rsp_status ac_tlm_lock::writel( uint32_t l)
{
 //
  lock = 0;
  return SUCCESS;
}

/** Internal Read
  * Note: Always read 32 bits
  * @param a is the address to read
  * @param d id the data that will be read
  * @returns A TLM response packet with SUCCESS and a modified d
*/
ac_tlm_rsp_status ac_tlm_lock::readl(uint32_t &d)
{
 //Modificar big endian
  if(lock == 0) {
    lock = 1;
    d = 0;
    return SUCCESS;
  }
  else {
    d = 1;
    return SUCCESS;
  }
  //SUCCESS ERROR;
}



